class TypeIncidentsController < ApplicationController
  # GET /type_incidents
  # GET /type_incidents.xml
  def index
    @type_incidents = TypeIncident.all

    respond_to do |format|
      format.html {render :layout => 'layout'} # index.html.erb
      format.xml  { render :xml => @type_incidents }
    end
  end

  # GET /type_incidents/1
  # GET /type_incidents/1.xml
  def show
    @type_incident = TypeIncident.find(params[:id])

    respond_to do |format|
      format.html {render :layout => 'layout'} # show.html.erb
      format.xml  { render :xml => @type_incident }
    end
  end

  # GET /type_incidents/new
  # GET /type_incidents/new.xml
  def new
    @type_incident = TypeIncident.new

    respond_to do |format|
      format.html {render :layout => 'layout'} # new.html.erb
      format.xml  { render :xml => @type_incident }
    end
  end

  # GET /type_incidents/1/edit
  def edit
    @type_incident = TypeIncident.find(params[:id])
	
	respond_to do |format|
      format.html {render :layout => 'layout'} # new.html.erb
      format.xml  { render :xml => @type_incident }
    end
  end

  # POST /type_incidents
  # POST /type_incidents.xml
  def create
    @type_incident = TypeIncident.new(params[:type_incident])

	respond_to do |format|
	  if @type_incident.save
		flash[:notice] = 'Le type d\'incident a &eacute;t&eacute; cr&eacute;&eacute;.'
		format.html { redirect_to(@type_incident) }
		format.xml  { render :xml => @type_incident, :status => :created, :location => @type_incident }
	  else
		format.html { render :action => "new", :layout => 'layout' }
		format.xml  { render :xml => @type_incident.errors, :status => :unprocessable_entity }
	  end
	end
	
  end

  # PUT /type_incidents/1
  # PUT /type_incidents/1.xml
  def update
    @type_incident = TypeIncident.find(params[:id])

    respond_to do |format|
      if @type_incident.update_attributes(params[:type_incident])
        flash[:notice] = "Le type d'incident a été mis à jour."
        format.html { redirect_to(@type_incident) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit", :layout => 'layout' }
        format.xml  { render :xml => @type_incident.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /type_incidents/1
  # DELETE /type_incidents/1.xml
  def destroy
    @type_incident = TypeIncident.find(params[:id])
    @type_incident.destroy

    respond_to do |format|
      format.html { redirect_to(type_incidents_url) }
      format.xml  { head :ok }
    end
  end
end
